#include "createuser.h"
#include "ui_createuser.h"

#include <QDebug>

CreateUser::CreateUser(QWidget *parent) :
    Base(parent),
    ui(new Ui::CreateUser)
{
    ui->setupUi(this);

    ui->create_now_Rbt->setChecked(true);
}

CreateUser::~CreateUser()
{
    delete ui;
}

void CreateUser::start()
{
    ui->stackedWidget->setCurrentIndex(0);
}

bool CreateUser::previewStep()
{
    if (ui->stackedWidget->currentIndex() == 1) {
        ui->stackedWidget->setCurrentIndex(0);
        return false;
    }

    return true;
}

bool CreateUser::nextStep()
{
    if (ui->create_now_Rbt->isChecked()) {
        if (ui->stackedWidget->currentIndex() == 0) {
            ui->stackedWidget->setCurrentIndex(1);
            return false;
        } else if (ui->stackedWidget->currentIndex() == 1) {
            return checkDataValid();
        }
    }

    return true;
}

bool CreateUser::checkDataValid()
{
    // TODO check data valid
    return true;
}

void CreateUser::on_create_now_Rbt_released()
{
    //TODO create user now
    qInfo() << "------create user now";
}


void CreateUser::on_create_later_Rbt_released()
{
    //TODO create user later
    qInfo() << "------create user later";
}

